<template>
  <div>
    <el-card class="box-card">
      <div class="news_header">
        <MainSearchForm :formList="formList" :formValue="formValue" @formReset="formChange" @formSearch="formChange"></MainSearchForm>
        <!-- <el-button size="mini" type="primary" class="add-btn" @click="addNews">新增</el-button> -->
      </div>
      <div class="main_table mg-t-0" style="min-height: 600px">
        <MainTable
          ref="orderTable"
          :loading="listLoading"
          :columns="columns"
          :tableData="tableData"
          showIndex
        >
          <template v-slot:qualification="{ row }">
            <div class="qualification">
              <!-- <div @click="openFileds(row.company_qualification)" v-html="`${row.company_qualification}`" v-if="row.company_qualification"></div> -->
            </div>
          </template>
          <el-table-column label="操作" width="200">
            <template slot-scope="scope">
              
            </template>
          </el-table-column>
        </MainTable>
      </div>
      <div class="pagination-right">
        <MainPagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="currentPage"
          :page-sizes="[10, 20, 30, 40]"
          :page-size="pageSize"
          layout=" ->,total, sizes, prev, pager, next, jumper"
          :total="total"
        >
        </MainPagination>
      </div>
    </el-card>
  </div>
</template>

<script>
import { getCompanyVideoList } from "@/api/traceability/index";
import { apiUrl, objKeySort, Md5 } from "@/utils/public";
import MainTable from '@/components/MainTable/table.vue'
import { indexData } from '../MockData'
const { columns, formList, formValue } = indexData
export default {
  name: "news",
  components: {
    MainTable
  },
  data() {
    return {
      formList,
      formValue,
      tableData: [],
      currentPage: 1,
      pageSize: 10,
      total: 0,
      // 勾选的数据
      multipleSelection: [],
      listLoading: false,
      columns,
    };
  },
  activated() {
    this.getData();
  },

  methods: {
    //  表单搜索
    formChange() {
      this.currentPage = 1
      this.pageSize = 20
      this.getData()
    },
    getData() {
      this.listLoading = true;
      let data = {
        page: this.currentPage,
        page_size: this.pageSize,
        ...this.formValue
      };
      let query = Object.assign(
        {
          sign: Md5(
            objKeySort(Object.assign(apiUrl().name, data)) + apiUrl().appsecret
          ),
        },
        apiUrl().name,
        data,
      );
      getCompanyVideoList(query).then(
        (res) => {
          this.listLoading = false;
          this.tableData = res.data.list;
          this.total = res.data.count;
          this.formList[2].options = res.data.region_list.map(el => {
            return {
              label: el.mername,
              value: el.id
            }
          })
        },
        (err) => {
          console.log(err);
        }
      );
    },
    close(){
      location.reload()
    },
    // 勾选的数据
    handleSelectionChange(val) {
      console.log("val", val);
      this.multipleSelection = val;
    },
    handleSizeChange(val) {
      this.pageSize = val;
      this.getData();
    },
    handleCurrentChange(val) {
      this.currentPage = val;
      this.getData();
    }
  },
  created() {
  },
};
</script>
<style lang="scss" scoped>
@import '../index.scss';
</style>
